﻿@using X.PagedList;
@using X.PagedList.Mvc.Core;
@using X.PagedList.Mvc.Common;
@using FwProject.Distribution.Dto
@using FwProject.Core.Distribution
@model IPagedList<DistributionLineViewList>
@{
    Layout = null;
    int count = 0;
    int SumDistributioncount = 0;
    int SumDistributionSetcount = 0;
    int SumRecoverycount = 0;
    int SumRecoveryBycount = 0;
    int SumExchangegoodscount = 0;
    int SumExchangegoodsSetcount = 0;
    int SumDamagecount = 0;
    int SumGivecount = 0;
    int SumGiveSetcount = 0;
    int SumBackboxcount = 0;
    int SumBacknumbercount = 0;
    int x = 0;
    if (Model.Count > 0)
    {
        if (Model.PageNumber != 1)
        {

            x = (Model.PageNumber - 1) * Model.PageSize;
        }
    }
}
<div id="table_print" style="max-height:600px;overflow-y:scroll;">

    <table class="table table-bordered table-hover table-rowselected">
        <thead>
            <tr>
                <th style="width:45px">序号</th>
                <th>线路名称</th>
                <th>货品型号</th>
                <th>配送箱数</th>
                <th>配送套数</th>
                <th>回收箱数</th>
                <th>回收套数</th>
                <th>换货箱数</th>
                <th>换货套数</th>
                <th>赠送箱数</th>
                <th>赠送套数</th>
                <th>退回箱数</th>
                <th>退回套数</th>
                <th>折损套数</th>
                @*<th style="width:200px;">操作</th>*@
            </tr>
        </thead>
        <tbody>
            @if (Model.Count == 0)
            {
                <tr><td class="text-center" colspan="10">暂无数据</td></tr>
            }
            else
            {
                foreach (var item in Model)
                {
                    x++;
                    count = item.DistributionLineList.Count + 1;

                    if (item.DistributionLineList.Count == 0)
                    {
                        <tr>
                            <td rowspan="2">@x</td>
                            <td rowspan="2">@item.LineName</td>
                            <td colspan="12" style="text-align:center;">无配送信息</td>
                        </tr>
                    }
                    else
                    {
                        int i = 0;
                        foreach (var chilitem in item.DistributionLineList)
                        {
                            if (chilitem != null)
                            {
                                <tr>
                                    @if (i == 0)
                                    {
                                        <td rowspan="@count">@x</td>
                                        <td rowspan="@count">@item.LineName</td>
                                        <td>@chilitem.TypeNumberName</td>
                                        <td>@chilitem.Distributioncount</td>
                                        <td>@chilitem.DistributionSetcount</td>
                                        <td>@chilitem.Recoverycount</td>
                                        <td>@chilitem.RecoverySetcount</td>
                                        <td>@chilitem.Exchangegoodscount</td>
                                        <td>@chilitem.ExchangegoodsSetcount</td>
                                        <td>@chilitem.Givecount</td>
                                        <td>@chilitem.GiveSetcount</td>
                                        <td>@chilitem.Backboxcount</td>
                                        <td>@chilitem.Backnumbercount</td>
                                        <td>@chilitem.Damagecount</td>
                                    }
                                    else
                                    {
                                        <td>@chilitem.TypeNumberName</td>
                                        <td>@chilitem.Distributioncount</td>
                                        <td>@chilitem.DistributionSetcount</td>
                                        <td>@chilitem.Recoverycount</td>
                                        <td>@chilitem.RecoverySetcount</td>
                                        <td>@chilitem.Exchangegoodscount</td>
                                        <td>@chilitem.ExchangegoodsSetcount</td>
                                        <td>@chilitem.Givecount</td>
                                        <td>@chilitem.GiveSetcount</td>
                                        <td>@chilitem.Backboxcount</td>
                                        <td>@chilitem.Backnumbercount</td>
                                        <td>@chilitem.Damagecount</td>

                                    }
                                </tr>
                                SumDistributioncount += chilitem.Distributioncount;
                                SumDistributionSetcount += chilitem.DistributionSetcount;
                                SumRecoverycount += chilitem.Recoverycount;
                                SumRecoveryBycount += chilitem.RecoverySetcount;
                                SumExchangegoodscount += chilitem.Exchangegoodscount;
                                SumExchangegoodsSetcount += chilitem.ExchangegoodsSetcount;
                                SumDamagecount += chilitem.Damagecount;
                                SumGivecount += chilitem.Givecount;
                                SumGiveSetcount += chilitem.GiveSetcount;
                                SumBackboxcount += chilitem.Backboxcount;
                                SumBacknumbercount += chilitem.Backnumbercount;
                            }
                            else
                            {
                                <tr>
                                    <td rowspan="2">@x</td>
                                    <td rowspan="2">@item.LineName</td>
                                    <td colspan="12" style="text-align:center;">无配送信息</td>
                                </tr>
                            }
                            i++;
                        }
                    }
                    <tr style="background-color:lightsteelblue">
                        <td>合计</td>
                        <td>@(item.DistributionLineList.Sum(o => o?.Distributioncount))</td>
                        <td>@(item.DistributionLineList.Sum(o => o?.DistributionSetcount))</td>
                        <td>@(item.DistributionLineList.Sum(o => o?.Recoverycount))</td>
                        <td>@(item.DistributionLineList.Sum(o => o?.RecoverySetcount))</td>
                        <td>@(item.DistributionLineList.Sum(o => o?.Exchangegoodscount))</td>
                        <td>@(item.DistributionLineList.Sum(o => o?.ExchangegoodsSetcount))</td>
                        <td>@(item.DistributionLineList.Sum(o => o?.Givecount))</td>
                        <td>@(item.DistributionLineList.Sum(o => o?.GiveSetcount))</td>
                        <td>@(item.DistributionLineList.Sum(o => o?.Backboxcount))</td>
                        <td>@(item.DistributionLineList.Sum(o => o?.Backnumbercount))</td>
                        <td>@(item.DistributionLineList.Sum(o => o?.Damagecount))</td>
                    </tr>
                }
                <tr class="footer">
                    <td style="color:red">合计</td>
                    <td colspan="2"></td>
                    <td style="color:red">@SumDistributioncount</td>
                    <td style="color:red">@SumDistributionSetcount</td>
                    <td style="color:red">@SumRecoverycount</td>
                    <td style="color:red">@SumRecoveryBycount</td>
                    <td style="color:red">@SumExchangegoodscount</td>
                    <td style="color:red">@SumExchangegoodsSetcount</td>
                    <td style="color:red">@SumGivecount</td>
                    <td style="color:red">@SumGiveSetcount</td>
                    <td style="color:red">@SumBackboxcount</td>
                    <td style="color:red">@SumBacknumbercount</td>
                    <td style="color:red">@SumDamagecount</td>
                </tr>
            }
        </tbody>
    </table>

</div>
<div class="row pagedinfo">
    <div class="col-sm-5">
        @*共 @Model.TotalItemCount 条，@Model.PageSize 条/页 当前第 @Model.PageNumber/@Model.PageCount 页*@
        共 @Model.TotalItemCount 条，
        <select class="form-control" id="pageSize" style="width:70px;display:initial">
            @for (int z = 10; z < 100; z = z + 10)
            {
                if (z == Model.PageSize)
                {
                    <option selected value="@z">@z</option>
                }
                else
                {
                    <option value="@z">@z</option>
                }
            }
        </select> &nbsp;条/页 当前第 @Model.PageNumber/@Model.PageCount 页
    </div>
    <div class="col-sm-7">
        <input type="hidden" id="pageurl" value="&LineId=@(Context.Request.Query["LineId"])&beginTime=@(Context.Request.Query["beginTime"])&endTime=@(Context.Request.Query["endTime"])" />
        @Html.PagedListPager(Model, page => Url.Action("DistributionLine", new { pageIdx = page, size = Context.Request.Query["size"], LineId = Context.Request.Query["LineId"], beginTime = Context.Request.Query["beginTime"], endTime = Context.Request.Query["endTime"] }), PagedListRenderOptions.EnableUnobtrusiveAjaxReplacing(new AjaxOptions() { AllowCache = false, HttpMethod = "Get", UpdateTargetId = "data_list", OnSuccess = "AjaxSuccessCallback", OnBegin = "AjaxBegin" }))
    </div>
</div>